package api.utils;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class DataProviderTest1 {

	//迭代四次
	@Test(dataProvider = "testdb")
    public void parameterIntTest(Class clzz, String str) {
       System.out.println("Parameterized Number is : " + clzz);
       System.out.println("Parameterized Number is : " + str);
    }

    //This function will provide the patameter data
    @DataProvider(name = "testdb")
    public Object[][] parameterIntTestProvider() {
        return new Object[][]{
                   {Vector.class, "test1"},
                   {String.class, "test2"},
                   {Integer.class, "test3"},
                   {Integer.class, "test4"}
                  };
    }


    @Test(dataProvider = "testdb2", threadPoolSize = 20)
    public void parameterIntTest2(TestBean testBean) {
        System.out.println(Thread.currentThread().getName()+" : "+ testBean);
    }

    @DataProvider(name = "testdb2",parallel = true)
    public Iterator<Object[]> parameterIntTestProvider2() {
      List<Object[]> list =new ArrayList<>();
        for (int i = 0; i <100 ; i++) {
            list.add(new Object[]{new TestBean("msg"+i,20+i,"男")});
        }
      return  list.iterator();
    }

}
